import Vue from 'vue'
import Vuex from 'vuex'
import ly from './ly'
Vue.use(Vuex)
export default new Vuex.Store({

	state: {
		typename: '1',
		loginName: "login",
		isclicklogin: false,
		url: "http://localhost:7001",
		modelCarbox: false, //公共模
		isCarclic: false,
		isAddress: false, //添加地址没有？
		cakeArr: [], //放蛋糕
		breadArr: [], //放面包
		snackA: [], //放小食
		parts: [], //放配件
		userCar: [], //购物车商品
		goodsId: '', //当前点击商品的id
		isclickcar: false, //是否显示添加商品的弹框
		loginName: "login",
		userImg: "",
		total: ""
	},
	mutations: {
		changeisclicklogin(state) {
			state.isclicklogin = !state.isclicklogin;
		},
		changeTypeNmame(state, obj) {
			state.typename = obj
		},
		alertModelcar(state) {
			if (state.modelCarbox) {
				state.modelCarbox = false
			} else {
				state.modelCarbox = true
			}
		},
		changeisAddress(state) {
			state.isAddress = true
		},
		alertisCarclic(state) {
			state.isCarclic = !state.isCarclic
		},
		changeLoginName(state, obj) {
			state.loginName = obj
		},
		changeUserCar(state, obj) {
			state.userCar = obj
		},
		changeparts(state, obj) {
			state.parts = obj
		},
		initUserimg(state, obj) {
			state.userImg = obj
		},
		changegoodsFlag(state, obj) {
			state.userCar.map((el) => {
				el.flag = obj
			})
		},
		delectCarGoods(state, index) {
			state.userCar.splice(index, 1)
		},
		changeGoodsid(state, goods_id) {
			state.goodsId = goods_id
		},
		changeIsclickcar(state) {
			state.isclickcar = !state.isclickcar
		},
		changecakeArr(state, obj) {
			state.cakeArr = obj
		},
		changebreadArr(state, obj) {
			state.breadArr = obj
		},
		changesnakeArr(state, obj) {
			state.snackA = obj
		},
		//首页信息
		totalDate(state, obj) {
			state.total = obj
		}
	},
	actions: {},
	modules: {
		ly
	} 
})

